<!--
描述：楼房信息组件
开发人：fwb
开发日期：2017年8月22日
-->
<template lang="pug">
    keep-alive
        kalix-table(bizKey="examStudent" title='考生信息列表'  v-bind:targetURL="targetURL"
        v-bind:bizDialog="bizDialog" v-bind:bizSearch="'ExamStudentSearch'" v-bind:customToolBar="customToolBar"
        v-bind:toolbarBtnList="toolbarBtnList" v-bind:btnList="btnList" v-bind:dictDefine="dictDefine" v-bind:customTableTool="customTableTool"
        v-bind:isFixedColumn="isFixedColumn" ref="kalixTable" v-on:afterDialogClose="dialogClose")
            template(slot="tableColumnSlot")
                el-table-column(prop="barCode" label="条形码" align="center")
                el-table-column(prop="examNumber" label="考号" align="center")
                el-table-column(prop="examName" label="考生姓名" align="center")
                el-table-column(prop="identificationCard" label="身份证" align="center")
                el-table-column(prop="majorName" label="专业" align="center")
                el-table-column(prop="province" label="省份" align="center")
                el-table-column(prop="university" label="毕业院校" align="center")
                el-table-column(prop="address" label="联系地址" align="center")
                el-table-column(prop="phone" label="联系电话" align="center")
</template>

<script type="text/ecmascript-6">
    import {ExamStudentsURL} from '../../config.toml'
    import {examStudentBtnList} from './config.js'
    import FormModel from './examStudentModel'

    export default {
        name: 'kalix-enrolment-examinee',
        data() {
            return {
                formModel: Object.assign({}, FormModel),
                btnList: examStudentBtnList,
                dictDefine: [{
                    cacheKey: 'ENROLMENT-DICT-KEY',
                    type: '考生专业',
                    targetField: 'majorName',
                    sourceField: 'major'
                }],
                targetURL: ExamStudentsURL,
                bizDialog: [
                    {id: 'view', dialog: 'ExamStudentView'},
                    {id: 'edit', dialog: 'ExamStudentAdd'},
                    {id: 'importExcel', dialog: 'ExamStudentImport'},
                    {id: 'newAdd', dialog: 'ExamStudentAdd'},
                    {id: 'addScore', dialog: 'ExamScoreAdd'}
                ],
                toolbarBtnList: [
                    {id: 'add', isShow: false},
                    {id: 'newAdd', title: '添加', isShow: true, icon: 'icon-add'},
                    {id: 'importExcel', title: '导入Excel', isShow: true, icon: 'icon-add'},
                    // {id: 'addScore', title: '成绩录入', isShow: true, icon: 'icon-add'},
                ],
                isFixedColumn: true
            }
        },
        components: {},
        created() {
        },
        activated() {
        },
        deactivated() {
        },
        methods: {
            customToolBar(btnId, table) {
                switch (btnId) {
                    case 'newAdd': {
                        this.onNewAdd(table)
                        break
                    }
                    case 'importExcel': {
                        this.onImportExcel(table)
                        break
                    }
                    case 'addScore': {
                        this.onScoreAdd(table)
                        break
                    }
                }
            },
            onNewAdd(table) {
                //this.table = table
                let dig =
                    table.bizDialog.filter((item) => {
                        return item.id === 'newAdd'
                    })
                table.whichBizDialog = dig[0].dialog
                setTimeout(() => {
                    this.formModel = Object.assign({}, FormModel)
                    table.$refs.kalixDialog.$refs.kalixBizDialog.open('添加', false, this.formModel)
                }, 20)
            },
            onScoreAdd(table) {
                //this.table = table
                console.log(table)
                let dig =
                    table.bizDialog.filter((item) => {
                        return item.id === 'addScore'
                    })
                table.whichBizDialog = dig[0].dialog
                setTimeout(() => {
                    this.formModel = Object.assign({}, FormModel)
                    table.$refs.kalixDialog.$refs.kalixBizDialog.open('成绩录入', false, this.formModel)
                }, 20)
            },
            onImportExcel(table) {
                let dig =
                    table.bizDialog.filter((item) => {
                        return item.id === 'importExcel'
                    })
                table.whichBizDialog = dig[0].dialog
                setTimeout(() => {
                    table.$refs.kalixDialog.$refs.kalixBizDialog.open('批量导入', false, '')
                }, 20)
            },
            customTableTool(row, btnId, that) {
                switch (btnId) {
                    case 'newEdit': {
                        this.onNewEdit(row, that)
                        break
                    }
                }
            },
            dialogClose() {
                this.$refs.kalixTable.refresh()
            }
        }
    }
</script>

<style scoped lang="stylus">
</style>
